<template>
  <view>
    <u-navbar :is-back="false" title="首页"></u-navbar>
    <view class="head">
      <view style="padding-bottom: 150rpx"></view>
      <u-swiper width="650" height="400" :border-radius="20" :list="swiper"></u-swiper>
    </view>
    <view style="margin-top: 15%">
      <u-card @click="navigateTo('/pages/article/index?type=2')" sub-title="更多>" :head-style="{fontWeight:'bold'}"
              show-head title="新闻中心">
        <view slot="body">
          <u-card v-for="ob in news">
            <view slot="body">
              <view style="width: 100%;display: flex">
                <view style="width: 40%">
                  <img style="width: 200rpx;height: 150rpx" :src="ob.cover"/>
                </view>
                <view style="width: 60%">
                  <view style="height: 100rpx" class="u-type-info u-line-2">{{ ob.title }}</view>
                  <view>
                    {{ ob.createTime }}
                  </view>
                </view>
              </view>
            </view>
          </u-card>
        </view>
      </u-card>
    </view>
    <view style="margin-top: 5%">
      <u-card @click="navigateTo('/pages/article/index?type=3')" sub-title="更多>" :head-style="{fontWeight:'bold'}"
              show-head title="校友风采">
        <view slot="body">
          <u-swiper height="400" :border-radius="20" :list="alumnus"></u-swiper>
        </view>
      </u-card>
    </view>

  </view>
</template>
<script>


import {allSwipers} from "@/api/card/swiper";
import UNavbar from "@/uview-ui/components/u-navbar/u-navbar.vue";
import {listArticle} from "@/api/card/article";

export default {
  components: {UNavbar},
  data() {
    return {
      swiper: [],
      news: [],
      alumnus: [],
    }
  },
  onLoad() {
    this.getSwiper()
    listArticle({pageNum: 1, pageSize: 3, type: 2}).then(re => {
      this.news = re.rows
    })
    allSwipers({type: 3}).then(re => {
      for (let ob of re.data) {
        this.alumnus.push({image: ob.url})
      }
    })
  },
  methods: {
    getSwiper() {
      allSwipers({type: 1}).then(re => {
        for (let ob of re.data) {
          this.swiper.push({image: ob.url})
        }
      })
    },

  },
  onShow() {

  },

};
</script>

<style lang="scss" scoped>
.head {
  position: relative;
  height: 500rpx;
  background-image: url('https://njjtj.itssky.com:7991/profile/upload/2024/05/03/background_20240503173112A021.png');
  background-size: cover
}
</style>
